package org.unit.testmgmt.ui.generator.wizard;

import org.eclipse.jface.wizard.WizardPage;
import org.unit.testmgmt.generator.wizard.GeneratorWizardBase;
import org.unit.testmgmt.tml.UTMModel;

/**
 * Base class for the wizard pages.
 * 
 * @author Robert Streng
 *
 */
public abstract class GeneratorWizardBasePage extends WizardPage {

	protected GeneratorWizardBase controller;
	
	public void init() {
		getController().initPage();
	};

	/**
	 * Updates the UTM-Model.
	 */
	public void update() {
		getController().updateModel();
	};
	
	/**
	 * Constructor
	 * 
	 * @param title
	 * @param description
	 * @param pageName
	 * @param model
	 */
	public GeneratorWizardBasePage(String title, String description, String pageName, UTMModel model) {
		super(pageName);
		setTitle(title);
		setDescription(description);
		createController(model);
	}

	/**
	 * @return the wizard-controller
	 */
	protected GeneratorWizardBase getController() {
		return controller;
	};
	
	/**
	 * Creates the wizard-controller.
	 * 
	 * @param model
	 */
	protected abstract void createController(UTMModel model);

	/**
	 * Updates the page status.
	 * 
	 * @param message
	 */
	public void updateStatus(String message) {
		setErrorMessage(message);
		setPageComplete(message == null);
	}
	
}
